<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>商家登录</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        :root {
            --primary-color: #1989fa;
            --text-color: #333;
            --border-color: #ddd;
            --error-color: #f44336;
            --success-color: #4caf50;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            font-size: 14px;
            line-height: 1.5;
            color: var(--text-color);
            background-color: #f5f5f5;
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }

        .login-container {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: center;
            padding: 20px;
            max-width: 400px;
            margin: 0 auto;
            width: 100%;
        }

        .login-header {
            text-align: center;
            margin-bottom: 30px;
        }

        .brand-logo {
            width: 80px;
            height: 80px;
            margin: 0 auto 15px;
            background: var(--primary-color);
            border-radius: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .brand-logo i {
            font-size: 40px;
            color: white;
        }

        .login-header h1 {
            font-size: 24px;
            color: var(--primary-color);
            margin-bottom: 10px;
        }

        .login-header p {
            color: #666;
            font-size: 14px;
        }

        .login-tabs {
            display: flex;
            margin-bottom: 20px;
            border-bottom: 1px solid var(--border-color);
        }

        .login-tab {
            flex: 1;
            text-align: center;
            padding: 10px;
            cursor: pointer;
            color: #666;
            position: relative;
        }

        .login-tab.active {
            color: var(--primary-color);
        }

        .login-tab.active:after {
            content: '';
            position: absolute;
            bottom: -1px;
            left: 20%;
            right: 20%;
            height: 2px;
            background: var(--primary-color);
        }

        .form-group {
            margin-bottom: 15px;
            position: relative;
        }

        .form-control {
            width: 100%;
            padding: 12px;
            padding-left: 40px;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            font-size: 14px;
            transition: all 0.3s;
        }

        .form-control:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(25, 137, 250, 0.1);
        }

        .form-group i {
            position: absolute;
            left: 12px;
            top: 50%;
            transform: translateY(-50%);
            color: #999;
        }

        .verify-group {
            display: flex;
            gap: 10px;
        }

        .verify-group .form-control {
            flex: 1;
        }

        .verify-btn {
            padding: 0 15px;
            background: none;
            border: 1px solid var(--primary-color);
            border-radius: 8px;
            color: var(--primary-color);
            font-size: 14px;
            cursor: pointer;
            white-space: nowrap;
        }

        .btn {
            width: 100%;
            padding: 12px;
            background-color: var(--primary-color);
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            margin-top: 20px;
            cursor: pointer;
            transition: opacity 0.3s;
        }

        .btn:hover {
            opacity: 0.9;
        }

        .footer-links {
            text-align: center;
            margin-top: 20px;
            color: #666;
        }

        .footer-links a {
            color: var(--primary-color);
            text-decoration: none;
            margin: 0 10px;
        }

        .divider {
            display: flex;
            align-items: center;
            margin: 30px 0;
            color: #999;
        }

        .divider::before,
        .divider::after {
            content: '';
            flex: 1;
            height: 1px;
            background: var(--border-color);
        }

        .divider span {
            padding: 0 15px;
            font-size: 12px;
        }

        .social-login {
            display: flex;
            justify-content: center;
            gap: 20px;
        }

        .social-btn {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            border: 1px solid var(--border-color);
            display: flex;
            align-items: center;
            justify-content: center;
            color: #666;
            text-decoration: none;
            transition: all 0.3s;
        }

        .social-btn:hover {
            color: var(--primary-color);
            border-color: var(--primary-color);
        }

        .error-message {
            color: var(--error-color);
            font-size: 12px;
            margin-top: 5px;
            display: none;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <div class="login-header">
            <div class="brand-logo">
                <i class="fas fa-store"></i>
            </div>
            <h1>商家登录</h1>
            <p>欢迎使用商家管理系统</p>
        </div>
        
        <div class="login-tabs">
            <div class="login-tab active" onclick="switchTab('password')">密码登录</div>
            <div class="login-tab" onclick="switchTab('verify')">验证码登录</div>
        </div>

        <form id="loginForm" onsubmit="return validateForm(event)">
            <div class="form-group">
                <i class="fas fa-mobile-alt"></i>
                <input type="text" class="form-control" id="phone" placeholder="请输入手机号">
                <div class="error-message" id="phoneError"></div>
            </div>

            <div id="passwordLogin">
                <div class="form-group">
                    <i class="fas fa-lock"></i>
                    <input type="password" class="form-control" id="password" placeholder="请输入密码">
                    <div class="error-message" id="passwordError"></div>
                </div>
            </div>

            <div id="verifyLogin" style="display: none;">
                <div class="form-group verify-group">
                    <div style="position: relative; flex: 1;">
                        <i class="fas fa-shield-alt"></i>
                        <input type="text" class="form-control" id="verifyCode" placeholder="请输入验证码">
                    </div>
                    <button type="button" class="verify-btn" onclick="sendVerifyCode()">获取验证码</button>
                </div>
            </div>

            <button type="submit" class="btn">登录</button>
        </form>
        
        <div class="footer-links">
            <a href="#">忘记密码</a>
            <a href="register.html">注册账号</a>
        </div>

        <div class="divider">
            <span>其他登录方式</span>
        </div>

        <div class="social-login">
            <a href="#" class="social-btn">
                <i class="fab fa-weixin"></i>
            </a>
            <a href="#" class="social-btn">
                <i class="fab fa-qq"></i>
            </a>
        </div>
    </div>

    <script>
        function switchTab(type) {
            const tabs = document.querySelectorAll('.login-tab');
            const passwordLogin = document.getElementById('passwordLogin');
            const verifyLogin = document.getElementById('verifyLogin');

            tabs.forEach(tab => tab.classList.remove('active'));
            if (type === 'password') {
                tabs[0].classList.add('active');
                passwordLogin.style.display = 'block';
                verifyLogin.style.display = 'none';
            } else {
                tabs[1].classList.add('active');
                passwordLogin.style.display = 'none';
                verifyLogin.style.display = 'block';
            }
        }

        function validateForm(event) {
            event.preventDefault();
            let isValid = true;
            const phone = document.getElementById('phone');
            const phoneError = document.getElementById('phoneError');
            const password = document.getElementById('password');
            const passwordError = document.getElementById('passwordError');

            // 手机号验证
            if (!/^1[3-9]\d{9}$/.test(phone.value)) {
                phoneError.textContent = '请输入正确的手机号';
                phoneError.style.display = 'block';
                isValid = false;
            } else {
                phoneError.style.display = 'none';
            }

            // 密码验证
            if (password.value.length < 6) {
                passwordError.textContent = '密码不能少于6位';
                passwordError.style.display = 'block';
                isValid = false;
            } else {
                passwordError.style.display = 'none';
            }

            if (isValid) {
                // 这里添加登录逻辑
                window.location.href = 'home.html';
            }

            return false;
        }

        let canSendCode = true;
        let countdown = 60;

        function sendVerifyCode() {
            if (!canSendCode) return;
            
            const phone = document.getElementById('phone');
            const phoneError = document.getElementById('phoneError');
            const verifyBtn = document.querySelector('.verify-btn');

            if (!/^1[3-9]\d{9}$/.test(phone.value)) {
                phoneError.textContent = '请输入正确的手机号';
                phoneError.style.display = 'block';
                return;
            }

            canSendCode = false;
            verifyBtn.disabled = true;
            
            let timer = setInterval(() => {
                verifyBtn.textContent = `${countdown}秒后重试`;
                countdown--;
                
                if (countdown < 0) {
                    clearInterval(timer);
                    verifyBtn.textContent = '获取验证码';
                    verifyBtn.disabled = false;
                    canSendCode = true;
                    countdown = 60;
                }
            }, 1000);

            // 这里添加发送验证码的逻辑
        }
    </script>
</body>
</html>